package dwz.business.lotto.impl;

import java.util.List;

import dwz.business.lotto.ZhuDanInterface;
import dwz.common.util.web.PageInfo;
import dwz.persistence.beans.QiHao;
import dwz.persistence.beans.YongHu;
import dwz.persistence.beans.ZhuDan;
import dwz.persistence.beans.ZhuDanExample;
import dwz.persistence.mapper.ZhuDanMapper;
import dwz.web.vo.CountBbVO;
import dwz.web.vo.FronCountByQiHaoVO;
import dwz.web.vo.YiChiCondition;
import dwz.web.vo.ZhuDanVo;

import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Transactional(rollbackFor = Exception.class)
@Service
public class ZhuDanInterfaceImpl implements ZhuDanInterface{

	@Autowired
	ZhuDanMapper zhuDanMapper;
	@Override
	public int countByExample(ZhuDanExample example) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int deleteByExample(ZhuDanExample example) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int deleteByPrimaryKey(Integer id) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int insertSelective(ZhuDan record) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public List<ZhuDan> selectByExample(ZhuDanExample example) {
 
		return zhuDanMapper.selectByExample(example);
	}
	
	@Override
	public List<ZhuDan> selectByExampleWithPage(ZhuDanExample example,
			PageInfo pageInfo) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public ZhuDan selectByPrimaryKey(Integer id) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int updateByPrimaryKeySelective(ZhuDan entity) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public List<ZhuDan> selectAllWithPage(ZhuDan entity, PageInfo pageInfo) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public ZhuDan selectEntityByExample(ZhuDanExample example) {
		// TODO Auto-generated method stub
		return null;
	}
	/**
	  * lpx添加
	  * @param zhuDan
	  * @return
	  */
		public List<ZhuDanVo> selectList(ZhuDan zhuDan) {
			 
			return zhuDanMapper.selectList(zhuDan);
		}
	@Override
	public List<CountBbVO> countRi(QiHao qiHao,ZhuDan zhuDan) {
		List<CountBbVO> list = zhuDanMapper.countRi(zhuDan);
		int i = 0;
			for(CountBbVO vo1 : list ){
				vo1.setXh(++i);
				if(vo1.getZjje()!=null){  //开奖号码出来了可以统计，否则不要显示
					vo1.setZjje(vo1.getZjje()==null?0:vo1.getZjje()+(vo1.getZs()==null?0:vo1.getZs()));
					vo1.setZjzyk(vo1.getZcyk()==null?0:vo1.getZcyk()+(vo1.getZjzs()==null?0:vo1.getZjzs()));
					vo1.setSjyk(vo1.getZjje()-vo1.getZjzyk());
				}
				vo1.setSjzt(vo1.getZt()-(vo1.getZjchi()==null?0:vo1.getZjchi()));
		  }
		
		return list;
	}
	
	
	@Override
	public List<CountBbVO> countYue(ZhuDan zhuDan) {
		
		List<CountBbVO> list1 = zhuDanMapper.countYue(zhuDan);
		int i = 0;
			for(CountBbVO vo : list1){
				vo.setXh(++i);
				if(vo.getZjje()!=null){
					vo.setZjje(vo.getZjje()+(vo.getZs()==null?0:vo.getZs()));
					vo.setZjzyk(vo.getZcyk()==null?0:vo.getZcyk()+(vo.getZjzs()==null?0:vo.getZjzs()));
					vo.setSjyk(vo.getZjje()-vo.getZjzyk());
				}
				vo.setSjzt(vo.getZt()-(vo.getZjchi()==null?0:vo.getZjchi()));
			}
		
		return list1;
	}
	
	public List<CountBbVO> countYue2(ZhuDan zhuDan){
		
		List<CountBbVO> list1 = zhuDanMapper.countYue2(zhuDan);
		int i = 0;
			for(CountBbVO vo : list1){
				vo.setXh(++i);
					if(vo.getZjje()!=null){
						vo.setZjje(vo.getZjje()+(vo.getZs()==null?0:vo.getZs()));
						vo.setZjzyk(vo.getZcyk()==null?0:vo.getZcyk()+(vo.getZjzs()==null?0:vo.getZjzs()));
						vo.setSjyk(vo.getZjje()-vo.getZjzyk());
					}
					vo.setSjzt(vo.getZt()-(vo.getZjchi()==null?0:vo.getZjchi()));
			}
		
		return list1;
	}

	@Override
	public Float selectDaiLiYiChiMoney(YiChiCondition yiChiCondition) {
		Float daiFloat = zhuDanMapper.selectDaiLiYiChiMoney(yiChiCondition);
		return daiFloat == null?0.0f:daiFloat;
	}

	@Override
	public List<ZhuDan> selectTopTen(ZhuDanExample zhuDanExample) {
		RowBounds rowBounds = new RowBounds(0, 10);		
		return zhuDanMapper.selectByExample(zhuDanExample,rowBounds);
	}

	@Override
	public List<FronCountByQiHaoVO> frontCountByQiHao(YongHu yongHu) {
		// TODO Auto-generated method stub
		return zhuDanMapper.frontCountByQiHao(yongHu);
	}


	


}
